src_root = ./HttPeek/Sources
util_root = ./HttPeek/Utilities

compile := clang -g -Os -target arm64-apple-ios8.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -I$(util_root) -I$(src_root)

ApplicationPeek.o: $(src_root)/ApplicationPeek.m
	$(compile) -o ApplicationPeek.o -c $(src_root)/ApplicationPeek.m

ConnectionPeek.o: $(src_root)/ConnectionPeek.m
	$(compile) -o ConnectionPeek.o -c $(src_root)/ConnectionPeek.m

HttpeekMain.o: $(src_root)/HttpeekMain.m
	$(compile) -o HttpeekMain.o -c $(src_root)/HttpeekMain.m

NotificationPeek.o: $(src_root)/NotificationPeek.m
	$(compile) -o NotificationPeek.o -c $(src_root)/NotificationPeek.m

ReadStreamPeek.o: $(src_root)/ReadStreamPeek.m
	$(compile) -o ReadStreamPeek.o -c $(src_root)/ReadStreamPeek.m

SessionPeek.o: $(src_root)/SessionPeek.m
	$(compile) -o SessionPeek.o -c $(src_root)/SessionPeek.m

SSLPeek.o: $(src_root)/SSLPeek.m
	$(compile) -o SSLPeek.o -c $(src_root)/SSLPeek.m

WebViewPeek.o: $(src_root)/WebViewPeek.m
	$(compile) -o WebViewPeek.o -c $(src_root)/WebViewPeek.m

HookUtil.o: $(util_root)/HookUtil.c
	$(compile) -o HookUtil.o -c $(util_root)/HookUtil.c

NSData+GZIP.o: $(util_root)/NSData+GZIP.m
	$(compile) -o NSData+GZIP.o -c $(util_root)/NSData+GZIP.m

NSUtil.o: $(util_root)/NSUtil.m
	$(compile) -o NSUtil.o -c $(util_root)/NSUtil.m

objs := ApplicationPeek.o \
	ConnectionPeek.o \
	HttpeekMain.o \
	NotificationPeek.o \
	ReadStreamPeek.o \
	SessionPeek.o \
	SSLPeek.o \
	WebViewPeek.o \
	HookUtil.o \
	NSData+GZIP.o \
	NSUtil.o

lib: $(objs)
	clang -g -dynamiclib -target arm64-apple-ios8.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -Xlinker -install_name -Xlinker httpeek.so -o ../Httpeek/httpeek.so $(objs) -lobjc.A -framework Foundation -lz
clean:
	rm *.o
